let shenSha = {
  子: [],
  丑: [],
  寅: [],
  寅: [],
  卯: [],
  辰: [],
  巳: [],
  午: [],
  未: [],
  申: [],
  酉: [],
  戌: [],
  亥: [],
};
let initShenSha = {
  子: [],
  丑: [],
  寅: [],
  寅: [],
  卯: [],
  辰: [],
  巳: [],
  午: [],
  未: [],
  申: [],
  酉: [],
  戌: [],
  亥: [],
};
function getPropertyNameByElement(element) {
  for (let key in shenSha) {
    if (shenSha.hasOwnProperty(key)) {
      if (shenSha[key].includes(element)) {
        return key;
      }
    }
  }
  return null;
}
// 处理年煞
function handleYearshenSha(gzYear) {
  let s = gzYear[0],
    b = gzYear[1];
  shenSha[getStepSha(b, 0)] = shenSha[getStepSha(b, 0)].concat(["太岁"]);
  shenSha[getStepSha(b, 2)] = shenSha[getStepSha(b, 2)].concat(["丧门"]);
  shenSha[getStepSha(b, -2)] = shenSha[getStepSha(b, -2)].concat(["吊客"]);
  shenSha[getStepSha(b, 6)] = shenSha[getStepSha(b, 6)].concat([
    "岁破",
    "大耗",
  ]);
  shenSha[getStepSha(b, -5)] = shenSha[getStepSha(b, -5)].concat(["岁墓"]);
  shenSha[getStepSha(b, -1)] = shenSha[getStepSha(b, -1)].concat(["病符"]);
  shenSha[getStepSha(b, -4)] = shenSha[getStepSha(b, -4)].concat(["岁虎"]);
  shenSha[getStepSha(b, 4)] = shenSha[getStepSha(b, 4)].concat(["官符"]);
  shenSha[getStepSha(b, 1)] = shenSha[getStepSha(b, 1)].concat(["太阳"]);
  shenSha[getStepSha(b, 3)] = shenSha[getStepSha(b, 3)].concat(["合神"]);
  shenSha[getStepSha(b, 5)] = shenSha[getStepSha(b, 5)].concat(["小耗"]);
}
// 处理月煞
// 处理日煞
function handleDayshenSha() {}
// 处理旬煞
// 处理季煞
function handleSeasonshenSha() {
  let season = "";
  console.log(season);

  switch (season) {
    case "春":
      shenSha.子 = shenSha.子.concat(["太岁"]);
      shenSha.寅 = shenSha.寅.concat(["丧门"]);
      shenSha.戌 = shenSha.戌.concat(["吊客"]);
      shenSha.午 = shenSha.午.concat(["岁破", "大耗"]);
      shenSha.未 = shenSha.未.concat(["岁墓"]);
      shenSha.亥 = shenSha.亥.concat(["病符"]);
      shenSha.酉 = shenSha.酉.concat(["将军"]);
      shenSha.申 = shenSha.申.concat(["岁虎"]);
      shenSha.辰 = shenSha.辰.concat(["官符"]);
      break;
    case "夏":
      shenSha.寅 = shenSha.寅.concat(["丧门"]);
      shenSha.戌 = shenSha.戌.concat(["吊客"]);
      shenSha.午 = shenSha.午.concat(["岁破", "大耗"]);
      shenSha.未 = shenSha.未.concat(["岁墓"]);
      shenSha.亥 = shenSha.亥.concat(["病符"]);
      shenSha.酉 = shenSha.酉.concat(["将军"]);
      shenSha.申 = shenSha.申.concat(["岁虎"]);
      shenSha.辰 = shenSha.辰.concat(["官符"]);
      break;
    case "秋":
      shenSha.寅 = shenSha.寅.concat(["丧门"]);
      shenSha.戌 = shenSha.戌.concat(["吊客"]);
      shenSha.午 = shenSha.午.concat(["岁破", "大耗"]);
      shenSha.未 = shenSha.未.concat(["岁墓"]);
      shenSha.亥 = shenSha.亥.concat(["病符"]);
    case "冬":
      shenSha.丑 = shenSha.丑.concat(["浴盆", "天目"]);
      shenSha.戌 = shenSha.戌.concat(["寡宿", "关神"]);
      shenSha.午 = shenSha.午.concat(["岁破", "大耗"]);
      shenSha.未 = shenSha.未.concat(["天喜", "天耳"]);
      shenSha.亥 = shenSha.亥.concat(["皇书", "战雄"]);
      shenSha.卯 = shenSha.卯.concat(["火鬼"]);
      shenSha.酉 = shenSha.酉.concat(["丧车"]);
  }
}

function getStepSha(dz, step) {
  const arr = [
    "子",
    "丑",
    "寅",
    "卯",
    "辰",
    "巳",
    "午",
    "未",
    "申",
    "酉",
    "戌",
    "亥",
  ];
  const index = arr.indexOf(dz);
  if (index === -1) {
    throw new Error("输入的元素不在数组中");
  }
  const newIndex = (index + step) % arr.length;
  return arr[newIndex < 0 ? newIndex + arr.length : newIndex];
}
function getAllShenSha(gzDate) {
  shenSha = {...initShenSha}; // 重置shenSha
  handleYearshenSha(gzDate.year);
  return shenSha;
}
// 分类处理
// handleYearshenSha();
// handleSeasonshenSha();

console.log(shenSha);

export { getAllShenSha };
